Ext.define('appmod.view.role.authorization.ModuleFunctionList', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.authmodulefunctionlistpanel',
    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            columns: [
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'name',
                    text: '功能名称',
					width: 100,
					sortable :false
                },
				{
            		header: '功能设定',
            		dataIndex: 'acl',
            		width: 60,
					renderer:function(value , metaData , record , rowIndex , colIndex , store ,  view) {
						var renName = '';						
						
						var aclColumn = me.down('gridcolumn[dataIndex=acl]');
						var dsEditor = null;
						if (!aclColumn.getEditor() )  {
							// --- build run store ---
							var actions = record.actions();
							var dataSrc = [];
							actions.each(function(rec) {
								var item = [rec.getId() , rec.get('name')];
								dataSrc.push(item);
							});
							dsEditor = Ext.create('Ext.data.ArrayStore', {
								storeId:'selectAclId',
								fields:['id' , 'name'],
								data:dataSrc
							})
							aclColumn.setEditor({
					    		xtype: 'combobox',
					    		typeAhead: true,
					    		triggerAction: 'all',
					    		selectOnTab: true,
								editable :false,
								store:dsEditor,
								displayField:'name',
								valueField: 'id', 
					    		lazyRender: true,
					    		listClass: 'x-combo-list-small'
							});
						} else {
							var editor = aclColumn.getEditor();
							dsEditor = editor.getStore();
						}
						
						dsEditor.each(function(comRec) {
							if (comRec.getId() == value) {
								renName = comRec.get('name');
								return;
							}
						});
						
						if (renName == "") {
							renName = "未设定";
						}	

						
						return renName;					
					}
										
        		}				
            ],
			selModel:{
				selType:'rowmodel'
			},
			plugins: [
				Ext.create('Ext.grid.plugin.CellEditing', {
					clicktoEdit:2
    			})
			],			
            viewConfig: {

            },
			dockedItems: [
			{
				xtype: 'toolbar',
				dock: 'top',
				items: [
				{
					xtype: 'button',
				    text: '保存功能授权',
					action:'auth'
				}
				]
			}]
        });

        me.callParent(arguments);
    }
});